fix(navigation-bar): move context provider to not wrap parent #6960
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The FixedNavigationBarContextProvider, which uses a ResizeObserver to respond to size changes on the navbar element, currently wraps that same element. This can result in unexpected ResizeObserver errors on initial render, when a media query is being used to determine layout. The context provider only needs to wrap the navbar's children, and by moving it down the React tree to only wrap the children and not the parent, the error goes away.
Proposed behaviour
No ResizeObserver errors should be raised when a NavigationBar component is rendered
Current behaviour
ResizeObserver errors are raised on initial render when padding is set by a media query
Checklist
d.ts
file added or updated if requiredQA
Additional context
Testing instructions
A Test story has been added to demonstrate the bug scenario and allow manual testing - when run without the code change that fixes the issue, this results in an error message related to ResizeObserver being rendered on the screen. (In Safari, this can also be seen on the Javascript console.) With the fix in place, this error no longer appears (either on screen or in the console, in any browser).
When regression testing, please pay particular attention to the NavigationBarWithSubmenuAndChangingHeight test story, as this is the one most likely to have been affected by this change (but I do not believe it will have been).